/* 
 * File:   servidor.cpp
 * Author: saulio
 *
 * Created on April 30, 2012, 9:16 PM
 */


#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <string.h>
#include <unistd.h>
#include <sys/types.h> 
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>


using namespace std;



int main() {
    
  
     unsigned int Quimera_port=3000;
     struct msghdr mh;
     
     struct iovec v[2];
     struct sockaddr_in serv_addr, cli_addr;
    
     int sockfd, r_n_bytes,h,r;
   
     
     sockfd = socket(AF_INET, SOCK_DGRAM, 0);
     v[0].iov_base=&h;
     v[0].iov_len=sizeof(h);
     v[1].iov_base=&r;
     v[1].iov_len=sizeof(r);
     bzero((char *) &serv_addr, sizeof(serv_addr));
     bzero((char *) &r, sizeof(r));
     serv_addr.sin_family=AF_INET;
     serv_addr.sin_addr.s_addr = INADDR_ANY;
     serv_addr.sin_port = htons(Quimera_port);
     bind(sockfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr));
     mh.msg_name =  &cli_addr;
     mh.msg_namelen = sizeof(cli_addr);
     mh.msg_iov = v;
     mh.msg_iovlen = 2;
    
    
    r_n_bytes=recvmsg(sockfd, &mh, 0);

         
   
         
        
    
     close(sockfd);
     return 0;
    
     
}
